<!DOCTYPE html>
<html lang="cn">
<head>
    <title>WSD Admin</title>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="__STATICURL__/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/bootstrap-responsive.min.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/uniform.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/select2.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/matrix-style.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/matrix-media.css"/>
    <link rel="stylesheet" href="__STATICURL__/css/bootstrap-wysihtml5.css"/>
    <link href="__STATICURL__/font-awesome/css/font-awesome.css" rel="stylesheet"/>
</head>
<body>
<include file="Common:header"/>
<div id="content">
    <!--breadcrumbs-->
    <div id="content-header">
        <div id="breadcrumb"><a href="__ROOT__/clover"><i class="icon-home"></i> 主页</a>
            <a href="__URL__">员工列表</a><a href="#" class="current">员工添加</a>
        </div>
    </div>
    <!--End-breadcrumbs-->
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box" style="margin-top:0px;">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>添加员工</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <table class="table table-bordered table-striped">
                            <tbody>
                            <tr class="odd gradeX">
                                <td>员工姓名</td>
                                <td>
                                    <div class="controls">
                                        <input style="width:258px;" type="text" value="" class="author_name"
                                               placeholder="输入员工姓名"/>
                                    </div>
                                </td>
                            </tr>
                            <tr class="odd gradeX">
                                <td>员工分类</td>
                                <td>
                                    <div class="control-group fl" style="width:200px;">
                                        <div class="controls" style="width:301px;">
                                            <select id="cat_id">
                                                <option value="0" selected="selected">-----选择员工分类-----</option>
                                                <foreach name="{category_list}" item="row">
                                                    <notempty name="row.p_level">
                                                        <option style="padding-left:{$row[p_level]*30}px;"
                                                                value="{$row.id}">
                                                            <for start="0" end="$row.p_level">&nbsp;&nbsp;&nbsp;</for>
                                                            {$row.cat_name}
                                                        </option>
                                                        <else/>
                                                        <option style="font-weight:bold;" value="{$row.id}">
                                                            {$row.cat_name}
                                                        </option>
                                                    </notempty>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr class="odd gradeX">
                                <td>员工排序</td>
                                <td>
                                    <div class="controls">
                                        <input style="width:258px;" type="text" value="" value="0" class="sort_order"
                                               placeholder="值越大越靠前"/>
                                    </div>
                                </td>
                            </tr>
                            <tr class="odd gradeX">
                                <td>员工风采</td>
                                <td>
                                    <div class=" fl">
                                        <span id="J_morepic_upload"></span>
                                        <input type="hidden" value="" id="J_pic_url">
                                    </div>
                                    <div class="widget-content  fl" style="border:none;padding:0;">
                                        <ul class="thumbnails picList">
                                            <ul>
                                    </div>
                                </td>
                            </tr>
                            <tr class="odd gradeX">
                                <td>简介简介</td>
                                <td>
                                    <div class="controls">
                                        <script id="contents" type="text/plain"
                                                style="width:99%;height:250px;"></script>
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td></td>
                                <td style="border-left:none;">
                                    <button type="" class="btn btn-success J_submit">保存</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--Footer-part-->
<include file="Common:footer"/>
<!--end-Footer-part-->
<script src="__STATICURL__/js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATICURL__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATICURL__/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATICURL__/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="__STATICURL__/js/jquery.ui.custom.js"></script>
<script src="__STATICURL__/js/bootstrap.min.js"></script>
<script src="__STATICURL__/js/jquery.uniform.js"></script>
<script src="__STATICURL__/js/select2.min.js"></script>
<script src="__STATICURL__/js/jquery.dataTables.min.js"></script>
<script src="__STATICURL__/js/matrix.js"></script>
<script src="__STATICURL__/js/matrix.tables.js"></script>

<script src="__STATICURL__/js/swfupload.js"></script>
<script src="__STATICURL__/js/swfupload.queue.js"></script>
<script src="__STATICURL__/js/fileprogress.js"></script>
<script src="__STATICURL__/js/handlers.js"></script>
</body>
</html>
<script type="text/javascript">
    var ue = UE.getEditor('contents');
    $(document).ready(function () {
        $(".J_submit").click(function (event) {
            var author_name = $(".author_name").val();
            var cat_id = $("#cat_id").val();
            var sort_order = $(".sort_order").val();
            var author_intro = UE.getEditor('contents').getContent();
            var author_img = $("#J_pic_url").val();
            if (author_name == "") {
                alert("输入员工姓名");
                $(".author_name").focus();
                return false;
            }
            if (author_intro == '') {
                alert("请输入员工简介！");
                author_intro.focus();
                return;
            }
            $.post('__URL__/do_add', {
                author_name: author_name,
                cat_id: cat_id,
                author_intro: author_intro,
                sort_order: sort_order,
                author_img: author_img
            }, function (res) {
                if (res) {
                    alert("成功");
                    window.location.href = "__URL__/index";
                } else {
                    alert("添加失败");
                }
            });
        });

        var settings = {
            flash_url: "__STATICURL__/js/swfupload.swf",
            upload_url: "__URL__/upload_cover",
            post_params: {"is_more": "yes"},
            file_size_limit: "100 MB",
            file_types: "*.jpg;*.gif;*.jpeg;*.png;",
            file_upload_limit: 100,
            file_queue_limit: 100,
            custom_settings: {
                progressTarget: "fsUploadProgress",
                cancelButtonId: "btnCancel"
            },
            debug: false,
            // Button settings
            button_width: "114",
            button_height: "32",
            button_placeholder_id: "J_morepic_upload",
            button_text_style: ".theFont { font-size: 16;}",
            button_cursor: -2,
            button_window_mode: "TRANSPARENT",
            button_action: -100,//-110多图片上传，-100但图片上传，-120文件上传
            button_image_url: "__STATICURL__/images/upload_place.png",

            file_queued_handler: fileQueued,
            file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_start_handler: banner_uploadStart,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: book_upload_Success,
            upload_complete_handler: uploadComplete
        };
        swfu = new SWFUpload(settings);

        $(".J_delete").live("click", function (event) {
            var id = $(this).attr("data-id");
            $.post('__URL__/do_delete_pic', {id: id}, function (res) {
                if (res) {
                    $(".li_place").fadeOut("fast");
                    $("#J_pic_url").val("");
                }
            }, "json");
        });
    });
</script>
